package com.tubi.线程池;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class demo {
    /*
    * static ExecutorService newCachedThreadPool()   创建一个默认的线程池
	static newFixedThreadPool(int nThreads)	    创建一个指定最多线程数量的线程池
    * */

    public static void main(String[] args) throws InterruptedException {
        //创建一个默认的线程池子
        ExecutorService executorService = Executors.newCachedThreadPool();
        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName()+"第一个");
        });

        Thread.sleep(2000);
        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName()+"第二个");
        });
        executorService.shutdown();
    }
}
